package com.tengju.user.domain.model.user;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDate;
import java.util.Arrays;

@AllArgsConstructor
public enum CommonDateListRangeEnum {

    NONE("none","20190101","20990101","默认时间列表"),

    APP_ASSOCIATION("app_association","20200701","now","腾炬app社群时间列表"),

    APP_DOMINATION_MARKET("app_domination_market","20200701","now","腾炬app区域市场时间列表"),

    APP_ADVERTISING_CNT("app_advertising_cnt","20190101","bonusMonth","腾炬app广告指数时间列表"),

    APP_MOTIVATION_RANK("app_motivation_rank","20210101","bonusMonth","腾炬app收益排行榜时间列表");




    private String key;

    private String startDate;

    private String endDate;

    private String desc;


    public static CommonDateListRangeEnum getByKey(String key) {
        return Arrays.stream(CommonDateListRangeEnum.values())
                .filter(v -> v.getKey().equals(key))
                .findFirst().orElse(NONE);
    }

    public String getKey() {
        return key;
    }

    public CommonDateRangeDetial getStartDate() {
        return new CommonDateRangeDetial(
                Integer.parseInt(this.startDate.substring(0,4)),
                Integer.parseInt(this.startDate.substring(4,6)),
                Integer.parseInt(this.startDate.substring(6))
        );
    }

    public String getEndDate() {
        return endDate;
    }

    public String getDesc() {
        return desc;
    }
}
